package com.atlatl.gwt.client.mapquest;

import java.util.ArrayList;

/**
 * MQManeuverCollection class is used as a helper around a group of maneuvers.
 * 
 * @author JMILLER
 * 
 */
public class MQManeuverCollection {

	/** All the maneuvers in the route. */
	private ArrayList maneuvers = new ArrayList();

	/** Add a new maneuver to the route. */
	void add(MQManeuver maneuver) {
		maneuvers.add(maneuver);
	}

	/** Remove a maneuver from the route. */
	void remove(MQManeuver maneuver) {
		maneuvers.remove(maneuver);
	}

	/** Remove all maneuvers from the route. */
	void clear() {
		maneuvers.clear();
	}

	/** Returns all the maneuvers in the route. */
	public ArrayList getManeuvers() {
		return maneuvers;
	}

	/** @return the estimated total time the entire route takes to drive. */
	public int getTotalTime() {
		int time = 0;

		for (int i = 0; i < maneuvers.size(); i++) {
			time += ((MQManeuver) maneuvers.get(i)).getTime();
		}

		return time;
	}

	/** @return the total distance the entire route takes to drive */
	public float getTotalDistance() {
		float distance = 0;

		for (int i = 0; i < maneuvers.size(); i++) {
			distance += ((MQManeuver) maneuvers.get(i)).getDistance();
		}

		return distance;
	}
}
